package com.kobeliu.controller;

import com.kobeliu.pojo.PayResult;
import com.kobeliu.service.PaymentOrderService;
import com.kobeliu.service.WxOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("paymentNotice")
@Slf4j
public class NotifyController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private WxOrderService wxOrderService;

    @Autowired
    private PaymentOrderService paymentOrderService;

    @RequestMapping(value = "wxpay")
    public void wxpay(HttpServletRequest request, HttpServletResponse response) throws IOException {
        log.info("支付成功后的微信支付异步通知");

        //获取微信支付结果
        PayResult result = wxOrderService.getWxPayResult(request.getInputStream());

    }
}
